############# 前置安装 #############
apt update && apt upgrade
apt install jq vim -y

########## 搜索框 Search ##########
search_text=$(whiptail --title "网易云音乐" --inputbox "搜索栏" 10 50 3>&1 1>&2 2>&3)
##################################
touch neteaseMusic_history
# sed -i "${search_text}" neteaseMusic_history
echo "${search_text}" >> neteaseMusic_history

sb=$(echo "${search_text}" | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g")

a=$(curl -fsSL "https://api.a632079.me/nm/search/${sb}?type=SONG&offset=0&limit=10" | jq .result.songs[0].id)
b=$(curl -fsSL 'https://api.a632079.me/nm/url/'$a | jq .data[0].url)

name=$(echo "当前播放：" && curl -fsSL "https://api.a632079.me/nm/search/${sb}?type=SONG&offset=0&limit=10" | jq .result.songs[0].name)
songer=$(echo "作者：" && curl -fsSL "https://api.a632079.me/nm/search/${sb}?type=SONG&offset=0&limit=10" | jq .result.songs[0].artists[0].name)

echo $name
echo $songer
echo "网络地址："$b
sleep 1
bash -c "termux-open-url "$b